package com.designpatterns.GuardedSuspention;

import java.util.concurrent.TimeUnit;

/**
 * Created by 41579 on 2017/6/1.
 */
public class ServerThread implements Runnable{
    private RequestQueue requestQueue;

    public ServerThread(RequestQueue requestQueue) {
        this.requestQueue = requestQueue;
    }

    @Override
    public void run() {
        while(true) {
            try {
                TimeUnit.SECONDS.sleep(4);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            requestQueue.put(new Request(Thread.currentThread().getName()));
        }
    }
}
